﻿using DevExpress.XtraEditors.DXErrorProvider;
using Dogshow.Model.Validation;
using FluentValidation.Results;
using Dogshow.Win.Helpers;

namespace Dogshow.Win.Models
{
    public class Pas : Model.Pas, IValidatable
    {
        private readonly PasValidator m_PasValidator;

        private ValidationResult m_ValidationResult;

        public Pas()
        {
            m_PasValidator = new PasValidator();
        }

        public void GetPropertyError(string propertyName, ErrorInfo info)
        {
            this.GetErrorsForProperty(propertyName, info);
        }

        public void GetError(ErrorInfo info)
        {
            this.GetErrors(info);
        }

        public bool IsValid { get; set; }

        public ValidationResult Validate()
        {
            m_ValidationResult = m_PasValidator.Validate(this);
            IsValid = m_ValidationResult.IsValid;
            return m_ValidationResult;
        }
    }
}